import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;

public class Enemy1 extends GameObject{

//	public Image image;
//	public int x, y;
	Rectangle rect;
	public long prevBullet1Time;

//	public boolean active;// 활성화 여부 -> 이 값이 false이면 관리 목록에서 제거
	public boolean upDown;
	public boolean target = true;
//	public int damageCount = 0;

	public Enemy1(Image image, Player player, Player2 player2) {
		this.image = image;
		x = Constants.SCREEN_WIDTH;

		if (target) {
			y = player.y;
			target = false;
		} else {
			
			y = player2.y;
		}
		rect = new Rectangle(image.getWidth(null)/2, image.getHeight(null)/2);
	}

	public void update() {
		x = (x - 10);
		if (x < 0 - image.getWidth(null)) {
			active = false;
		}
		if (upDown) {
			y += 5;
			if (y > Constants.SCREEN_HEIGHT - 100 - image.getHeight(null))
				upDown = false;
		} else {
			y -= 5;
			if (y < 100)
				upDown = true;
		}
		if(x<0-image.getWidth(null) || y<0-image.getHeight(null) || y>Constants.SCREEN_HEIGHT+image.getHeight(null)){

			active = false;
		}
	}

	public void render(Graphics g) {
		if (active) {// 활성 상태일 경우에만 화면에 출력
			g.drawImage(image, x, y, null);
		}
	}

	public Rectangle getArea() {
		rect.x = x;
		rect.y = y;
		return rect;
	}
}
